#include "musicbrainz_importer.h"

#include <musicbrainz3/webservice.h>
#include <musicbrainz3/query.h>
#include <musicbrainz3/model.h>
#include <iostream>

namespace plok {

    Musicbrainz_importer::Musicbrainz_importer()
    {

        MusicBrainz::Query q;
        MusicBrainz::ArtistResultList results;
            try {
                // Search for all artists matching the given name. Limit the results
                // to the 5 best matches.

                MusicBrainz::ArtistFilter f = MusicBrainz::ArtistFilter().name("nevermore").limit(5);
                results = q.getArtists(&f);
            }

            catch (MusicBrainz::WebServiceError &e) {
                std::cout << "Error: " << e.what() << std::endl;
            }

            for (MusicBrainz::ArtistResultList::iterator i = results.begin(); i != results.end(); i++) {
                MusicBrainz::ArtistResult *result = *i;
                MusicBrainz::Artist *artist = result->getArtist();
                std::cout << "Score   : " << result->getScore() << std::endl;
                std::cout << "Id      : " << artist->getId() << std::endl;
                std::cout << "Name    : " << artist->getName() << std::endl;
                std::cout << "SortName: " << artist->getSortName() << std::endl;
                std::cout << std::endl;
            }


    }

}
